{{template "admin/header.html"}}
<title>Install - gpress</title>
<link rel="stylesheet" type="text/css" href="{{basePath}}admin/css/login.css">
<script type="text/javascript" src="https://cdn.staticfile.org/js-sha3/0.8.0/sha3.min.js"></script>
<script type="text/javascript">

    function encrypt() {
        var password = document.getElementById('password').value
        var password2 = document.getElementById('password2').value
        if (password != password2) {
            alert('密码不一致')
            return false
        }
        document.getElementById('password').value = sha3_512(password)
    }
    /*
        function randomString(len) {    
            len = len || 32;
            var str = "+-*!@#$%^&*()<>,.;{}[]|0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
            var result = "";
            for (i = 0; i < len; i++) result += str.charAt(Math.floor(Math.random() * str.length));
            return result
        }
    */
    function changeInstall(type) {
        if (type == 'wallet') {
            $('#installForm').css('display', 'none')
            $('#installWalletForm').css('display', 'block')
            $('.walletInstall').css('display', 'none')
            $('.pwdInstall').css('display', 'block')
        } else {
            $('#installForm').css('display', 'block')
            $('#installWalletForm').css('display', 'none')
            $('.walletInstall').css('display', 'block')
            $('.pwdInstall').css('display', 'none')
        }
    }
</script>

</head>

<body>
    <section class="hero is-success is-fullheight">
        <div class="hero-body">
            <div class="container has-text-centered">
                <div class="column is-4 is-offset-4">
                    <h3 class="title has-text-black">初始化安装</h3>
                    <hr class="login-hr">

                    <form id="installForm" action="{{basePath}}admin/install" method="post" onsubmit="encrypt();">
                        <div class="field">
                            <div class="control">
                                <input class="input" name="account" type="text" placeholder="请输入管理员账号" autofocus="">
                            </div>
                        </div>

                        <div class="field">
                            <div class="control">
                                <input class="input" id="password" name="password" type="password"
                                    placeholder="请输入管理员密码">
                            </div>
                        </div>
                        <div class="field">
                            <div class="control">
                                <input class="input" id="password2" type="password" placeholder="请再次输入管理员密码">
                            </div>
                        </div>
                        <!-- 使用后端管理界面配置,jwtSecret也有后端随机产生-->
                        <!--
                            <div class="field">
                                <div class="control">
                                    <input class="input" name="port" type="text" value="2023"  placeholder="端口默认2023,重启生效" autofocus="">
                                </div>
                            </div>
                            <div class="field">
                                <div class="control">
                                    <input class="input" name="basePath" type="text"  placeholder="基本路径,默认为空,重启生效" autofocus="">
                                </div>
                            </div>
                            -->
                        <!--有服务端生成,前端传递过程中有被拦截监听的风险-->
                        <!--
                            <div class="field">
                                <div class="control">
                                    <input class="input" id="jwtSecret" name="jwtSecret" type="text"   placeholder="jwtSecret" autofocus="">
                                </div>
                            </div>
                             <div class="field">
                                <div class="control">
                                    <input class="input" name="jwttokenKey" type="text" value="jwttoken"  placeholder="jwttokenKey" autofocus="">
                                </div>
                            </div>
                            
                            <div class="field">
                                <div class="control">
                                    <input class="input" name="timeout" type="text" value="1800"  placeholder="timeout" autofocus="">
                                </div>
                            </div>
                            -->

                        <button class="button is-block is-info is-large is-fullwidth"> 安装 <i class="fa fa-sign-in"
                                aria-hidden="true"></i></button>
                    </form>

                    <form id="installWalletForm" action="{{basePath}}admin/install" method="post" onsubmit="encrypt();">
                        <div class="field">
                            <div class="control" style=" text-align: left;">
                                <label class="chainSelectLable" for="chainType">请选择链类型：</label>
                                <select class="input" id="chainType" name="chainType">
                                    <option value="ETH">以太坊</option>
                                    <option value="XUPER">百度超级链</option>
                                </select>
                            </div>
                        </div>
                        <div class="field">
                            <div class="control">
                                <input class="input" name="chainAddress" type="text" placeholder="请输入链地址" autofocus="">
                            </div>
                        </div>




                        <button class="button is-block is-info is-large is-fullwidth"> 安装 <i class="fa fa-sign-in"
                                aria-hidden="true"></i></button>
                    </form>

                    <div class="walletInstall" onclick="changeInstall('wallet')">使用区块链钱包</div>
                    <div class="walletInstall pwdInstall" onclick="changeInstall('pwd')">使用账户密码</div>


                </div>
            </div>
        </div>
    </section>

</body>

</html>